#include <bits/stdc++.h>
using namespace std;
int reversed (int n){
    int num = 0;
    while (n!=0){
        num = num*10 + n%10;
        n /= 10;
    }
    return num;
}

int main() {
    int n;
    cin>>n;
    for (int i = 0; i <= n; ++i) {
        if (reversed(i)==i) cout<<i<<std::endl;
    }
}
